﻿Imports System.Text
Imports D2L.Extensibility.AuthSdk
Imports RestSharp
Imports D2L.Extensibility.AuthSdk.Restsharp

<TestClass()>
Public Class GradeTeste

    Private _authObj As Authenticate.Authenticate = New Authenticate.Authenticate()
    Protected method As Authenticate.Service

    'http://docs.valence.desire2learn.com/res/grade.html#get--d2l-api-le-(version)-(orgUnitId)-grades-
    'Protected Const ROUTE_GRADES As String = "/d2l/api/le/" & GradeTeste.LP_VERSION & "/" & GradeTeste.LMS_ORG_UNIT & "/grades/"

    'http://docs.valence.desire2learn.com/res/grade.html#get--d2l-api-le-(version)-(orgUnitId)-grades-(gradeObjectId)
    'Protected Const ROUTE_GRADE As String = "/d2l/api/le/" & GradeTeste.LP_VERSION & "/" & GradeTeste.LMS_ORG_UNIT & "/grades/" & GradeTeste.LMS_GRADE_OBJ_ID

    'http://docs.valence.desire2learn.com/res/grade.html#get--d2l-api-le-(version)-(orgUnitId)-grades-schemes-
    'Protected Const ROUTE_GRADE_SCHEMES As String = "/d2l/api/le/" & GradeTeste.LP_VERSION & "/" & GradeTeste.LMS_ORG_UNIT & "/grades/schemes/"

    'http://docs.valence.desire2learn.com/res/grade.html#Grade.GradeValue
    'http://docs.valence.desire2learn.com/res/grade.html#get--d2l-api-le-(version)-(orgUnitId)-grades-values-(userId)-
    'Protected Const ROUTE_GRADES_VALUES_USER As String = "/d2l/api/le/" & GradeTeste.LP_VERSION & "/" & GradeTeste.LMS_ORG_UNIT & "/grades/values/" & GradeTeste.USER_ID_GRADE & "/"

    'http://docs.valence.desire2learn.com/res/grade.html#Grade.GradeValue
    'http://docs.valence.desire2learn.com/res/grade.html#get--d2l-api-le-(version)-(orgUnitId)-grades-values-myGradeValues-
    'Protected Const ROUTE_GRADES_VALUE_CURRENT_CONTEXT_USER As String = "/d2l/api/le/" & GradeTeste.LP_VERSION & "/" & GradeTeste.LMS_ORG_UNIT & "/grades/values/myGradeValues/"


    '--Erro 403
    <TestMethod()>
    Public Sub get_grades_org_unit()

        method = New Authenticate.Service

        Dim _response As RestSharp.IRestResponse(Of Grade.GradeObject) = _authObj.ExecuteService_with_UserContext(method.GetGradesOrgUnit, RestSharp.Method.GET, Type.GradeObject)

        Console.WriteLine("{0}{1}", "Response:", _response.ToString())
        Console.WriteLine("Response Content: {0}", _response.Content.ToString())

        Assert.IsNotNull(_response)
        Assert.AreEqual("OK", _response.StatusCode.ToString())

    End Sub
    '--Erro 403
    <TestMethod()>
    Public Sub get_grade_org_unit()

        method = New Authenticate.Service

        Dim _response As RestSharp.IRestResponse(Of Grade.GradeObject) = _authObj.ExecuteService_with_UserContext(method.GetGradeOrgUnit, RestSharp.Method.GET, Type.GradeObject)

        Console.WriteLine("{0}{1}", "Response:", _response.ToString())
        Console.WriteLine("Response Content: {0}", _response.Content.ToString())

        Assert.IsNotNull(_response)
        Assert.AreEqual("OK", _response.StatusCode.ToString())

    End Sub
    '--Erro 403
    <TestMethod()>
    Public Sub get_grades_schemes()

        method = New Authenticate.Service

        Dim _response As RestSharp.IRestResponse(Of Grade.GradeScheme) = _authObj.ExecuteService_with_UserContext(method.GetGradesSchemes, RestSharp.Method.GET, Type.GradeScheme)

        Console.WriteLine("{0}{1}", "Response:", _response.ToString())
        Console.WriteLine("Response Content: {0}", _response.Content.ToString())

        Assert.IsNotNull(_response)
        Assert.AreEqual("OK", _response.StatusCode.ToString())

    End Sub
    '--Erro 403
    <TestMethod()>
    Public Sub get_grade_value_user()

        method = New Authenticate.Service

        Dim _response As RestSharp.IRestResponse(Of Grade.GradeValue) = _authObj.ExecuteService_with_UserContext(method.GetGradeValueUser, RestSharp.Method.GET, Type.GradeValue)

        Console.WriteLine("{0}{1}", "Response:", _response.ToString())
        Console.WriteLine("Response Content: {0}", _response.Content.ToString())

        Assert.IsNotNull(_response)
        Assert.AreEqual("OK", _response.StatusCode.ToString())

    End Sub
    '--Erro 403
    <TestMethod()>
    Public Sub get_grade_value_current_context_user()

        method = New Authenticate.Service

        Dim _response As RestSharp.IRestResponse(Of Grade.GradeValue) = _authObj.ExecuteService_with_UserContext(method.GetGradeValueCurrentContextUser, RestSharp.Method.GET, Type.GradeValue)

        Console.WriteLine("{0}{1}", "Response:", _response.ToString())
        Console.WriteLine("Response Content: {0}", _response.Content.ToString())

        Assert.IsNotNull(_response)
        Assert.AreEqual("OK", _response.StatusCode.ToString())

    End Sub

End Class
